﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CarLoanSystemWeb.MasterPage;

namespace CarLoanSystemWeb.Page.ChangePassword
{
    public partial class ChangePasswordPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            wuc_change_password1.InfoMessege += new EventHandler(Call_InfoMessage);
            wuc_change_password1.ErrorMessege += new EventHandler(Call_ErrorMessage);
            wuc_change_password1.ErrorMessegeName += new EventHandler(Call_ErrorMessageName);
            wuc_change_password1.ErrorMessegePassword += new EventHandler(Call_ErrorMessegePassword);
        }

        private void Call_InfoMessage(object sender, EventArgs e)
        {
            InfoMessage("เปลี่ยนรหัสผ่านเรียบร้อยแล้ว");
            Response.AppendHeader("Refresh", "2; url=../Main/MainPage.aspx");
        }

        private void Call_ErrorMessage(object sender, EventArgs e)
        {
            ErrorMessage(sender.ToString());
        }

        private void Call_ErrorMessageName(object sender, EventArgs e)
        {
            ErrorMessage("รหัสผ่านเก่าผิด");
        }

        private void Call_ErrorMessegePassword(object sender, EventArgs e)
        {
            ErrorMessage("รหัสผ่านใหม่ไม่ตรงกัน");
        }

        private void InfoMessage(string msg)
        {
            ((MainMasterPage)this.Master).ShowInfoMessage(msg);
        }

        private void ErrorMessage(string msg)
        {
            ((MainMasterPage)this.Master).ShowErrorMessage(msg);
        }
    }
}